/**
 * Project: d20Engine
 * Created: Oct 21, 2006 by bebopJMM
 */
package org.rollinitiative.d20.entity;

import org.rollinitiative.d20.Adjustment;
import org.rollinitiative.d20.Adjustment.AdjustmentSource;
import org.rollinitiative.d20.schema.d20.SizeEnum;

/**
 * Enumeration of the sizes that an entity may be classified as. The modifiers comply to the D20
 * SRD.
 * 
 * @see http://www.d20srd.org/srd/combat/combatStatistics.htm
 * 
 * @author bebopjmm
 */
public enum Size {
    FINE(8, -16), DIMINUTIVE(4, -8), TINY(2, -4), SMALL(1, -2), MEDIUM(0, 0), LARGE_TALL(-1, 2), LARGE_LONG(-1, 2), HUGE_TALL(
            -2, 4), HUGE_LONG(-2, 4), GARGANTUAN_TALL(-4, 8), GARGANTUAN_LONG(-4, 8), COLOSSAL_TALL(-8, 16), COLOSSAL_LONG(
            -8, 16);

    private final int combatMod_;
    
    private final int grappleMod_;


    Size(int combatModifier, int grappleModifier)
    {
        combatMod_ = combatModifier;
        grappleMod_ = grappleModifier;
    }


    public int getCombatModifier()
    {
        return combatMod_;
    }

    public int getGrappleModifier()
    {
        return grappleMod_;
    }

    public static Adjustment generateCombatAdjustment(Size size)
    {
        return new Adjustment(AdjustmentSource.INHERENT, size.combatMod_, "Size");
    }

    public static Adjustment generateGrappleAdjustment(Size size)
    {
        return new Adjustment(AdjustmentSource.INHERENT, size.grappleMod_, "Size");
    }

    public static Size mapSizeEnum(SizeEnum size)
    {
        int sizeVal = size.enumValue().intValue();
        switch (sizeVal) {
        case SizeEnum.INT_FINE:
            return FINE;
        case SizeEnum.INT_DIMINUTIVE:
            return DIMINUTIVE;
        case SizeEnum.INT_TINY:
            return TINY;
        case SizeEnum.INT_SMALL:
            return SMALL;
        case SizeEnum.INT_MEDIUM:
            return MEDIUM;
        case SizeEnum.INT_LARGE_TALL:
            return LARGE_TALL;
        case SizeEnum.INT_LARGE_LONG:
            return LARGE_LONG;
        case SizeEnum.INT_HUGE_TALL:
            return HUGE_TALL;
        case SizeEnum.INT_HUGE_LONG:
            return HUGE_LONG;
        case SizeEnum.INT_GARGANTUAN_TALL:
            return GARGANTUAN_TALL;
        case SizeEnum.INT_GARGANTUAN_LONG:
            return GARGANTUAN_LONG;
        case SizeEnum.INT_COLOSSAL_TALL:
            return COLOSSAL_TALL;
        case SizeEnum.INT_COLOSSAL_LONG:
            return COLOSSAL_LONG;
        default:
            return Size.MEDIUM;
        }
    }
}
